///////////////////////////////////////////////////////////////////////
//  Filename	DialogEx.h
//	Class:		CDialogEx
//
//	Compiler:	Visual C++ 6.0
//
//	Version:	1.0
//
//	Created:	2004/12/23
//	Updated:	
//
//	Author:		Wang Yongliang
///////////////////////////////////////////////////////////////////////

#ifndef __DIALOGEX_H__
#define __DIALOGEX_H__

#if WINVER >= 0x0500
	#define I_OS_CAL GetSysColor(COLOR_ACTIVECAPTION) // CAL == CaptionActiveLeft.
	#define I_OS_CAR GetSysColor(COLOR_GRADIENTACTIVECAPTION) // CAR == CaptionActiveRight.
	#define I_OS_CIL GetSysColor(COLOR_INACTIVECAPTION) // CIL == CaptionInactiveLeft.
	#define I_OS_CIR GetSysColor(COLOR_GRADIENTINACTIVECAPTION) // CIR == CaptionInactiveRight.
#else
	#define I_OS_CAL GetSysColor(COLOR_ACTIVECAPTION) // CAL == CaptionActiveLeft.
	#define I_OS_CAR GetSysColor(COLOR_ACTIVECAPTION) // CAR == CaptionActiveRight.
	#define I_OS_CIL GetSysColor(COLOR_INACTIVECAPTION) // CIL == CaptionInactiveLeft.
	#define I_OS_CIR GetSysColor(COLOR_INACTIVECAPTION) // CIR == CaptionInactiveRight.
#endif

class CDialogEx : public CDialog
{
private:
	BOOL		m_bActive;					// whether active or not;
	CFont		m_fontCaption;				// normal system font for active caption
	CRect		m_rcCaption;				// caption rectangle
	CBitmap		m_bmCaption[2];				// bitmap captions active/inactive

protected:
	HICON		m_hIcon;
	COLORREF	m_crCaption_Active_Left,	// gradient colors 
				m_crCaption_Active_Right, 
				m_crCaption_Inactive_Left, 
				m_crCaption_Inactive_Right;

protected:
	virtual		BOOL OnInitDialog();
	virtual		afx_msg BOOL OnNcActivate(BOOL bActive);
	virtual		afx_msg void OnNcPaint();
	virtual		afx_msg void OnPaint();
	virtual		afx_msg HCURSOR OnQueryDragIcon();

	void		PaintCaption(BOOL bActive);
	void		PaintCaption() { PaintCaption(m_bActive); }
	void		CreateFonts();
	CBitmap*	GetCaptionBitmap(BOOL bActive);

public:
	CDialogEx (
		UINT nTemplate, 
		UINT uId_Icon, 
		CWnd* pParent = NULL,
		COLORREF crCaption_Active_Left = 0x00808000,//I_OS_CAL, 
		COLORREF crCaption_Active_Right = 0x00800080,//I_OS_CAR, 
		COLORREF crCaption_Inactive_Left = I_OS_CIL, 
		COLORREF crCaption_Inactive_Right = I_OS_CIR );

	virtual ~CDialogEx();

	DECLARE_MESSAGE_MAP()
};

class CCaptionRect : public CRect 
{
public:
	CCaptionRect(const CWnd& wnd); // use reference to deny NULL ptr
};

#endif // __DIALOGEX_H__